package org.example.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.core.userdetails.User;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequestMapping("/common")
public class LoginController {



    @PostMapping("getLoginUser")
    public Object getLoginUser() throws Exception {
        log.info("哈哈哈红红火火恍恍惚惚");
//        throw new Exception();
        return ((User)SecurityContextHolder.getContext().getAuthentication().getPrincipal()).getUsername();

    }

}
